<?php
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/ml_guang_config.php');

class guang_tag2 extends ml_controller
{
    private $order;
    private $tgid;
    private $tgid2;
    private $block;
    private $page;
    private $tag;
    private $tag2;
    
    public function initParam()
    {
        $this->order = $this->input('order') == 'new' ? 'new' : 'hot';
        $this->tag = $this->input('tag');         
        $this->tag2 = $this->input('tag2');
        $this->page = $page = (int)$this->input('page' , '' , 1);
        $page = $page < 1 ? 1 : $page;
        $page = $page > 30 ? 1 : $page;
        $this->block = ($page-1)*3;
        define('ML_GUANG_SEGMENT', $this->block);
    }
        
    public function checkParam()
    {
//        $aLmTag = ml_factory::load_standard_conf('lmTag');
//        if(!isset($aLmTag[$this->tgid]))
//            $this->redirect(ML_PAGE_GUANG);
        $is = Tool_string::isUtf8($this->tag);
        
        if(!$is) {
            $this->tag = Tool_string::gb2utf($this->tag);
        }
        $str = ml_tool_resid::getNickKey($this->tag);
        $this->tgid = substr($str,4,strlen($str));
        
        
        if(!empty($this->tag2)){
            $is = Tool_string::isUtf8($this->tag2);
            
            if(!$is) {
                $this->tag2 = Tool_string::gb2utf($this->tag2);
            }
            $str = ml_tool_resid::getNickKey($this->tag2);
            $this->tgid2 = substr($str,4,strlen($str));        
        }
    }
    public function main()
    {
        $dest = '';
        
        if(empty($this->tag2)){
            $page_type = 'tag_'.$this->order;
            $dest = $this->tgid;
        }else{
            $page_type = 'tag2_'.$this->order;
            $dest = $this->tgid.'/'.$this->tgid2;
        }

        /*
        $oGuang = new ml_biz_pin_guang();
        $aHtml = $oGuang->output($page_type , $this->block , $dest , $this->__visitor['uid']);
        
        $aBlockCnf = array(
            0 => 1,
        );
        $data['pins'] = ml_tool_pinOutput::groupPinByColumn($aHtml , 4 , $aBlockCnf);
        */
        $data['page_type'] = $this->order;

        $data['page_tag_id'] = $this->tgid;
        $data['page_tag_id2'] = $this->tgid2;
        $data['page_tag'] = $this->tag;
        $data['page_tag2'] = $this->tag2; 
        $data['pagetitle'] = $data['hot_tag'][$this->tgid]['tag'];
        $data['noh1'] = true;//logo无h1标签
        $data['righttag'] = null;//ml_tool_getdata::mlJsonData('righttag_'.$this->tgid,'righttag');
        $this->set_ria_version('201205311650');

        $tags = ml_tool_getdata::mlJsonData('tag2tag','tagdata');
        $data['tags'] = $tags[$this->tgid]['list'];
        $total_block = $oGuang->get_total_block();
        $this->set_scope_var('$totalPage' , ceil($total_block / 3));
        $this->set_scope_var('$currentPage' , $this->page);
        $this->set_scope_var('$segment' , 0);
        $this->set_scope_var('$lastSegment' , $this->block == $total_block - 1 ? true : false);
        $this->set_scope_var('$page_type' , $this->order);
        $this->set_scope_var('$tag' , $this->tgid);
        $this->set_scope_var('$tag2', $this->tgid2);
        if(!empty($this->tgid2)){
            $tag_name = $data['tags']['list'][$this->tgid2];
        }else{
            $tag = $data['tags']['tag'];
        }
        $data['name'] = $tag_name;
        $this->set_page_title($tag_name." - ".$tag_name."最潮单品，".$tag_name."女装，".$tag_name."搭配");    
        $this->page_output('lm::guang_tag2' , $data);
    }
    
}
new guang_tag2();
?>